
#ifndef MYMD5_H
#define MYMD5_H

#include "Entry/TExportUtil.h"

class TUTIL_API CMyMd5
{
	struct MyMD5_CTX
	{
		int		state[4];				/* state (ABCD) */
		int		count[2];				/* number of bits, modulo 2^64 (lsb first) */
		char	buffer[64];				/* input buffer */
	};

public:
	CMyMd5();
	virtual ~CMyMd5();

	/**
	* Md5Digest
	* 
	* @param pInput 
	* @param unInputLen 
	* @param Digest 
	* @return int success return 0, fail return -1
	*/
	int Md5Digest(const unsigned char *pInput, unsigned int unInputLen, unsigned char Digest[16]);

	/**
	* GetMd5Str
	* 
	* @param pInput 
	* @param unInputLen 
	* @param pOutput 
	* @param unOutputLen 
	* @return int success return 0, fail return -1
	*/
	int GetMd5Str(const unsigned char *pInput, unsigned int unInputLen, char *pOutput, unsigned int unOutputLen);

protected:
	void Md5_Digest(char *szSour, int iLen, char *szDest);
	void MD5Init(MyMD5_CTX *);
	void MD5Update(MyMD5_CTX *, char *, int);
	void MD5Final(char[16], MyMD5_CTX *);
};



#endif // MYMD5_H